Fix macOS build: std::jthread is unavailable on libc++#32
Merged
Conversation
std::jthread is not provided by the libc++ shipped on macos-latest, so the encoder and decoder failed to build there while Linux (libstdc++) passed. Switch both worker pools to std::thread for portability and consistency with the CLI decoder, and add a scope guard that joins every started worker even if thread construction throws mid-startup, preserving the exception-safe shutdown that std::jthread provided. Closes #5 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CI fails on
macos-latest(Debug tests + Release build) with:std::jthread(C++20) is not exposed by the libc++ shipped on the currentmacos-latestimage, while Linux (libstdc++) provides it — so Ubuntu and ASan/UBSan jobs pass and only macOS breaks. This is pre-existing onmain(a docs-only PR surfaced it) and unrelated to that doc change.Fix
std::jthreadtostd::thread(the only twostd::jthreaduses;main.cppalready usesstd::thread).WorkerJoinGuardthat joins every started worker on scope exit, so a partial launch that throws during thread construction cannot leave joinable threads and callstd::terminate. This preserves the exception-safe shutdownstd::jthreadgave for free and addresses the startup-safety concern in Make multithreaded encoder startup exception-safe #5.Verification
Built and tested locally on macOS (the failing platform):
cmake --buildsucceeds, nojthreadreferences remainctest: 2/2 suites passlac_cli selftest: all sample-rate/bit-depth round-trips passCloses #5